$value = wfMessage( $value )->text();
// interpolate variables
$m = array();
- while( preg_match( '/\$([0-9]*?)/sm', $value, $m ) ) {
+ while ( preg_match( '/\$([0-9]*?)/sm', $value, $m ) ) {
list( $src, $var ) = $m;
wfSuppressWarnings();
$varValue = $this->_context[$var];
return new $classname();
}
+ /**
+ * Generates array of language links for the current page
+ *
+ * @return array
+ * @public
+ */
+ public function getLanguages() {
+ global $wgHideInterlanguageLinks;
+ $out = $this->getOutput();
+
+ # Language links
+ $language_urls = array();
+
+ if ( !$wgHideInterlanguageLinks ) {
+ foreach ( $out->getLanguageLinks() as $languageLinkText ) {
+ $languageLinkParts = explode( ':', $languageLinkText, 2 );
+ $class = 'interwiki-' . $languageLinkParts[0];
+ unset( $languageLinkParts );
+ $languageLinkTitle = Title::newFromText( $languageLinkText );
+ if ( $languageLinkTitle ) {
+ $ilInterwikiCode = $languageLinkTitle->getInterwiki();
+ $ilLangName = Language::fetchLanguageName( $ilInterwikiCode );
+
+ if ( strval( $ilLangName ) === '' ) {
+ $ilLangName = $languageLinkText;
+ } else {
+ $ilLangName = $this->formatLanguageName( $ilLangName );
+ }
+
+ $language_urls[] = array(
+ 'href' => $languageLinkTitle->getFullURL(),
+ 'text' => $ilLangName,
+ 'title' => $languageLinkTitle->getText(),
+ 'class' => $class,
+ 'lang' => $ilInterwikiCode,
+ 'hreflang' => $ilInterwikiCode
+ );
+ }
+ }
+ }
+ return $language_urls;
+ }
+
/**
* initialize various variables and generate the template
*
global $wgScript, $wgStylePath;
global $wgMimeType, $wgJsMimeType;
global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version;
- global $wgDisableCounters, $wgSitename, $wgLogo, $wgHideInterlanguageLinks;
+ global $wgDisableCounters, $wgSitename, $wgLogo;
global $wgMaxCredits, $wgShowCreditsIfMax;
global $wgPageShowWatchingUsers;
global $wgArticlePath, $wgScriptPath, $wgServer;
}
$tpl->set( 'catlinks', $this->getCategories() );
- if( $out->isSyndicated() ) {
+ if ( $out->isSyndicated() ) {
$feeds = array();
- foreach( $out->getSyndicationLinks() as $format => $link ) {
+ foreach ( $out->getSyndicationLinks() as $format => $link ) {
$feeds[$format] = array(
'text' => $this->msg( "feed-$format" )->text(),
'href' => $link
$out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext );
$tpl->setRef( 'bodytext', $out->mBodytext );
- # Language links
- $language_urls = array();
-
- if ( !$wgHideInterlanguageLinks ) {
- foreach( $out->getLanguageLinks() as $languageLinkText ) {
- $languageLinkParts = explode( ':', $languageLinkText, 2 );
- $class = 'interwiki-' . $languageLinkParts[0];
- unset( $languageLinkParts );
- $languageLinkTitle = Title::newFromText( $languageLinkText );
- if ( $languageLinkTitle ) {
- $ilInterwikiCode = $languageLinkTitle->getInterwiki();
- $ilLangName = Language::fetchLanguageName( $ilInterwikiCode );
-
- if ( strval( $ilLangName ) === '' ) {
- $ilLangName = $languageLinkText;
- } else {
- $ilLangName = $this->formatLanguageName( $ilLangName );
- }
-
- $language_urls[] = array(
- 'href' => $languageLinkTitle->getFullURL(),
- 'text' => $ilLangName,
- 'title' => $languageLinkTitle->getText(),
- 'class' => $class,
- 'lang' => $ilInterwikiCode,
- 'hreflang' => $ilInterwikiCode
- );
- }
- }
- }
+ $language_urls = $this->getLanguages();
if ( count( $language_urls ) ) {
$tpl->setRef( 'language_urls', $language_urls );
} else {
$tpl->set( 'reporttime', wfReportTime() );
// original version by hansm
- if( !wfRunHooks( 'SkinTemplateOutputPageBeforeExec', array( &$this, &$tpl ) ) ) {
+ if ( !wfRunHooks( 'SkinTemplateOutputPageBeforeExec', array( &$this, &$tpl ) ) ) {
wfDebug( __METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n" );
}
if ( strval( $page ) !== '' ) {
$a['returnto'] = $page;
$query = $request->getVal( 'returntoquery', $this->thisquery );
- if( $query != '' ) {
+ if ( $query != '' ) {
$a['returntoquery'] = $query;
}
}
}
$returnto = wfArrayToCgi( $a );
- if( $this->loggedin ) {
+ if ( $this->loggedin ) {
$personal_urls['userpage'] = array(
'text' => $this->username,
'href' => &$this->userpageUrlDetails['href'],
# thickens, because the Title object is altered for special pages,
# so it doesn't contain the original alias-with-subpage.
$origTitle = Title::newFromText( $request->getText( 'title' ) );
- if( $origTitle instanceof Title && $origTitle->isSpecialPage() ) {
+ if ( $origTitle instanceof Title && $origTitle->isSpecialPage() ) {
list( $spName, $spPar ) = SpecialPageFactory::resolveAlias( $origTitle->getText() );
$active = $spName == 'Contributions'
&& ( ( $spPar && $spPar == $this->username )
'class' => $wgSecureLogin ? 'link-https' : ''
);
- if( $this->showIPinHeader() ) {
+ if ( $this->showIPinHeader() ) {
$href = &$this->userpageUrlDetails['href'];
$personal_urls['anonuserpage'] = array(
'text' => $this->username,
*/
function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
$classes = array();
- if( $selected ) {
+ if ( $selected ) {
$classes[] = 'selected';
}
- if( $checkEdit && !$title->isKnown() ) {
+ if ( $checkEdit && !$title->isKnown() ) {
$classes[] = 'new';
if ( $query !== '' ) {
$query = 'action=edit&redlink=1&' . $query;
}
$result = array();
- if( !wfRunHooks( 'SkinTemplateTabAction', array( &$this,
+ if ( !wfRunHooks( 'SkinTemplateTabAction', array( &$this,
$title, $message, $selected, $checkEdit,
&$classes, &$query, &$text, &$result ) ) ) {
return $result;
function makeTalkUrlDetails( $name, $urlaction = '' ) {
$title = Title::newFromText( $name );
- if( !is_object( $title ) ) {
+ if ( !is_object( $title ) ) {
throw new MWException( __METHOD__ . " given invalid pagename $name" );
}
$title = $title->getTalkPage();
wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this, &$preventActiveTabs ) );
// Checks if page is some kind of content
- if( $title->canExist() ) {
+ if ( $title->canExist() ) {
// Gets page objects for the related namespaces
$subjectPage = $title->getSubjectPage();
$talkPage = $title->getTalkPage();
$params = array();
}
// Loops over each variant
- foreach( $variants as $code ) {
+ foreach ( $variants as $code ) {
// Gets variant name from language code
$varname = $pageLang->getVariantname( $code );
// Appends variant link
$nav_urls = array();
$nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() );
- if( $wgUploadNavigationUrl ) {
+ if ( $wgUploadNavigationUrl ) {
$nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
- } elseif( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getUser() ) === true ) {
+ } elseif ( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getUser() ) === true ) {
$nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) );
} else {
$nav_urls['upload'] = false;
$ptool['active'] = $plink['active'];
}
foreach ( array( 'href', 'class', 'text' ) as $k ) {
- if ( isset( $plink[$k] ) )
+ if ( isset( $plink[$k] ) ) {
$ptool['links'][0][$k] = $plink[$k];
+ }
}
$personal_tools[$key] = $ptool;
}
case 'SEARCH':
// Search is a special case, skins should custom implement this
$boxes[$boxName] = array(
- 'id' => 'p-search',
- 'header' => $this->getMsg( 'search' )->text(),
+ 'id' => 'p-search',
+ 'header' => $this->getMsg( 'search' )->text(),
'generated' => false,
- 'content' => true,
+ 'content' => true,
);
break;
case 'TOOLBOX':
$msgObj = $this->getMsg( 'toolbox' );
$boxes[$boxName] = array(
- 'id' => 'p-tb',
- 'header' => $msgObj->exists() ? $msgObj->text() : 'toolbox',
+ 'id' => 'p-tb',
+ 'header' => $msgObj->exists() ? $msgObj->text() : 'toolbox',
'generated' => false,
- 'content' => $this->getToolbox(),
+ 'content' => $this->getToolbox(),
);
break;
case 'LANGUAGES':
if ( $this->data['language_urls'] ) {
$msgObj = $this->getMsg( 'otherlanguages' );
$boxes[$boxName] = array(
- 'id' => 'p-lang',
- 'header' => $msgObj->exists() ? $msgObj->text() : 'otherlanguages',
+ 'id' => 'p-lang',
+ 'header' => $msgObj->exists() ? $msgObj->text() : 'otherlanguages',
'generated' => false,
- 'content' => $this->data['language_urls'],
+ 'content' => $this->data['language_urls'],
);
}
break;
default:
$msgObj = $this->getMsg( $boxName );
$boxes[$boxName] = array(
- 'id' => "p-$boxName",
- 'header' => $msgObj->exists() ? $msgObj->text() : $boxName,
+ 'id' => "p-$boxName",
+ 'header' => $msgObj->exists() ? $msgObj->text() : $boxName,
'generated' => true,
- 'content' => $content,
+ 'content' => $content,
);
break;
}
} else {
if ( $hookContents ) {
$boxes['TOOLBOXEND'] = array(
- 'id' => 'p-toolboxend',
- 'header' => $boxes['TOOLBOX']['header'],
+ 'id' => 'p-toolboxend',
+ 'header' => $boxes['TOOLBOX']['header'],
'generated' => false,
- 'content' => "<ul>{$hookContents}</ul>",
+ 'content' => "<ul>{$hookContents}</ul>",
);
// HACK: Make sure that TOOLBOXEND is sorted next to TOOLBOX
$boxes2 = array();
$realAttrs = array(
'type' => 'search',
'name' => 'search',
+ 'placeholder' => wfMessage( 'searchsuggest-search' )->text(),
'value' => isset( $this->data['search'] ) ? $this->data['search'] : '',
);
$realAttrs = array_merge( $realAttrs, Linker::tooltipAndAccesskeyAttribs( 'search' ), $attrs );
// Reduce footer links down to only those which are being used
$validFooterLinks = array();
- foreach( $footerlinks as $category => $links ) {
+ foreach ( $footerlinks as $category => $links ) {
$validFooterLinks[$category] = array();
- foreach( $links as $link ) {
- if( isset( $this->data[$link] ) && $this->data[$link] ) {
+ foreach ( $links as $link ) {
+ if ( isset( $this->data[$link] ) && $this->data[$link] ) {
$validFooterLinks[$category][] = $link;
}
}